<template><div><h1 id="小程序相关问题" tabindex="-1"><a class="header-anchor" href="#小程序相关问题" aria-hidden="true">#</a> 小程序相关问题</h1>
<h3 id="canvas生成的二维码自适应各种机型。" tabindex="-1"><a class="header-anchor" href="#canvas生成的二维码自适应各种机型。" aria-hidden="true">#</a> canvas生成的二维码自适应各种机型。</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token comment">// 自适应二维码的方法</span>
<span class="token function">getCanvasWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">var</span> that <span class="token operator">=</span> <span class="token keyword">this</span>
  wx<span class="token punctuation">.</span><span class="token function">getSystemInfo</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    <span class="token function-variable function">success</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">res</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">var</span> v <span class="token operator">=</span><span class="token number">750</span> <span class="token operator">/</span> res<span class="token punctuation">.</span>windowWidth<span class="token punctuation">;</span><span class="token comment">//    设计稿尺寸/当前手机屏幕宽度</span>
      that<span class="token punctuation">.</span><span class="token function">setData</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
        <span class="token literal-property property">v</span><span class="token operator">:</span>v
      <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>

<span class="token comment">//qrcode配置宽高进行适配</span>
<span class="token keyword">new</span> <span class="token class-name">QRCode</span><span class="token punctuation">(</span><span class="token string">"qrcode"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
    <span class="token literal-property property">text</span><span class="token operator">:</span> e<span class="token punctuation">.</span>currentTarget<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>use_code<span class="token punctuation">,</span>
    <span class="token literal-property property">width</span><span class="token operator">:</span> <span class="token number">460</span><span class="token operator">/</span><span class="token keyword">this</span><span class="token punctuation">.</span>data<span class="token punctuation">.</span>v<span class="token punctuation">,</span>
    <span class="token literal-property property">height</span><span class="token operator">:</span> <span class="token number">460</span><span class="token operator">/</span><span class="token keyword">this</span><span class="token punctuation">.</span>data<span class="token punctuation">.</span>v<span class="token punctuation">,</span>
    <span class="token literal-property property">colorDark</span><span class="token operator">:</span> <span class="token string">"#000000"</span><span class="token punctuation">,</span>
    <span class="token literal-property property">colorLight</span><span class="token operator">:</span> <span class="token string">"#ffffff"</span><span class="token punctuation">,</span>
    <span class="token literal-property property">correctLevel</span><span class="token operator">:</span> QRCode<span class="token punctuation">.</span>CorrectLevel<span class="token punctuation">.</span><span class="token constant">H</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  
<span class="token comment">//在html中canvas写一个style的css样式设置一下宽高</span>
<span class="token operator">&lt;</span>canvas <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">'codeimg'</span> style<span class="token operator">=</span><span class="token string">'width:{{460/v}}px; height:{{460/v}}px'</span> disable<span class="token operator">-</span>scroll<span class="token operator">=</span><span class="token string">"true"</span> canvas<span class="token operator">-</span>id<span class="token operator">=</span><span class="token string">'qrcode'</span><span class="token operator">></span><span class="token operator">&lt;</span><span class="token operator">/</span>canvas<span class="token operator">></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="自定义弹窗显示二维码-禁止页面滚动" tabindex="-1"><a class="header-anchor" href="#自定义弹窗显示二维码-禁止页面滚动" aria-hidden="true">#</a> 自定义弹窗显示二维码 禁止页面滚动</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token comment">//1、最外层弹窗标签加一个属性</span>
catchtouchmove<span class="token operator">=</span><span class="token string">"true"</span>

<span class="token comment">//2、canvas添加一个属性</span>
disable<span class="token operator">-</span>scroll<span class="token operator">=</span><span class="token string">"true"</span>

<span class="token comment">// 3、有蒙层时 禁止滚动下方页面，蒙层可滚动</span>
@touchmove<span class="token punctuation">.</span>stop<span class="token punctuation">.</span>prevent
<span class="token comment">// 当弹层有滚动时建议加上scroll-view 组件 并定义高度，</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="跳转到别的小程序" tabindex="-1"><a class="header-anchor" href="#跳转到别的小程序" aria-hidden="true">#</a> 跳转到别的小程序</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code>wx<span class="token punctuation">.</span><span class="token function">navigateToMiniProgram</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token literal-property property">appId</span><span class="token operator">:</span> <span class="token string">'wx8e0746fdfcbf770c'</span><span class="token punctuation">,</span>    <span class="token comment">//另一个下程序的appId</span>
  <span class="token literal-property property">path</span><span class="token operator">:</span> <span class="token string">'/pages/yugao/yugao?token='</span><span class="token operator">+</span> wx<span class="token punctuation">.</span><span class="token function">getStorageSync</span><span class="token punctuation">(</span><span class="token string">'token'</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">'&amp;cityId='</span> <span class="token operator">+</span> wx<span class="token punctuation">.</span><span class="token function">getStorageSync</span><span class="token punctuation">(</span><span class="token string">'cityId'</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">'&amp;liveId='</span> <span class="token operator">+</span> e<span class="token punctuation">.</span>currentTarget<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>liveid<span class="token punctuation">,</span>
  <span class="token literal-property property">envVersion</span><span class="token operator">:</span> <span class="token string">"trial"</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="ios上面border-1rpx-有的时候边框显示不全" tabindex="-1"><a class="header-anchor" href="#ios上面border-1rpx-有的时候边框显示不全" aria-hidden="true">#</a> ios上面border:1rpx 有的时候边框显示不全</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token comment">//步骤1中wxml增加space的view后如下：</span>
<span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">'label-con'</span><span class="token operator">></span>
    <span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">'space'</span><span class="token operator">></span><span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>
    <span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">'label'</span><span class="token operator">></span>中国移动<span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>
    <span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">'label'</span><span class="token operator">></span>苏宁<span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>
    <span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">'label'</span><span class="token operator">></span>阿里巴巴<span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>
    <span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">'label'</span><span class="token operator">></span>华为<span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>
<span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>
<span class="token comment">//步骤1中wxss中增加space类为：</span>
<span class="token punctuation">.</span>space<span class="token punctuation">{</span>
    <span class="token literal-property property">width</span><span class="token operator">:</span> 1rpx<span class="token punctuation">;</span>
    <span class="token literal-property property">height</span><span class="token operator">:</span> <span class="token number">100</span><span class="token operator">%</span><span class="token punctuation">;</span>
    <span class="token literal-property property">float</span><span class="token operator">:</span> left<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="new-date-date-gettime-在苹果手机不兼容" tabindex="-1"><a class="header-anchor" href="#new-date-date-gettime-在苹果手机不兼容" aria-hidden="true">#</a> new Date(date).getTime()在苹果手机不兼容</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span>date<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token comment">// 用这个方法来获取时间戳，</span>
<span class="token comment">// 在苹果手机上就是NaN，在安卓手机就是没有问题！</span>

<span class="token comment">// 加班寻找解决办法，才在一个小角落发现，</span>
<span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span>date<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token comment">// 在苹果手机上是不兼容的。</span>
<span class="token comment">// 虽然是一个小小的兼容性问题，</span>

<span class="token comment">// 解决办法：</span>
<span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span>data<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">-</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span><span class="token punctuation">,</span><span class="token string">'/'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token comment">// data是字符串，格式类似于：'2018-09-09 23:23:23'</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="小程序支付后跳转到详情页还是未支付状态" tabindex="-1"><a class="header-anchor" href="#小程序支付后跳转到详情页还是未支付状态" aria-hidden="true">#</a> 小程序支付后跳转到详情页还是未支付状态；</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token comment">// 支付成功后轮循请求详情页接口，如果返回支付成功则结束轮循跳转到详情页</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>result<span class="token punctuation">.</span>order_status <span class="token operator">==</span> <span class="token string">'2'</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    wx<span class="token punctuation">.</span><span class="token function">hideLoading</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token function">clearInterval</span><span class="token punctuation">(</span>that<span class="token punctuation">.</span>myTimer<span class="token punctuation">)</span>
    wx<span class="token punctuation">.</span><span class="token function">reLaunch</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
       <span class="token literal-property property">url</span><span class="token operator">:</span> <span class="token string">'../orderDetail/orderDetail?id='</span><span class="token operator">+</span>order_id<span class="token punctuation">,</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
    that<span class="token punctuation">.</span>myTimer <span class="token operator">=</span> <span class="token function">setInterval</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
       that<span class="token punctuation">.</span><span class="token function">getPreOrderDetail</span><span class="token punctuation">(</span>order_id<span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="多行文本显示省略号" tabindex="-1"><a class="header-anchor" href="#多行文本显示省略号" aria-hidden="true">#</a> 多行文本显示省略号</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token literal-property property">overflow</span> <span class="token operator">:</span> hidden<span class="token punctuation">;</span>
text<span class="token operator">-</span>overflow<span class="token operator">:</span> ellipsis<span class="token punctuation">;</span>
<span class="token literal-property property">display</span><span class="token operator">:</span> <span class="token operator">-</span>webkit<span class="token operator">-</span>box<span class="token punctuation">;</span>
<span class="token operator">-</span>webkit<span class="token operator">-</span>line<span class="token operator">-</span>clamp<span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token operator">-</span>webkit<span class="token operator">-</span>box<span class="token operator">-</span>orient<span class="token operator">:</span> vertical<span class="token punctuation">;</span>

<span class="token comment">//单行显示省略号</span>
<span class="token literal-property property">overflow</span><span class="token operator">:</span> hidden<span class="token punctuation">;</span>
text<span class="token operator">-</span>overflow<span class="token operator">:</span> ellipsis<span class="token punctuation">;</span>
white<span class="token operator">-</span>space<span class="token operator">:</span> nowrap<span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="小程序文字换行-全是数字的话不会自动换行的解决方法" tabindex="-1"><a class="header-anchor" href="#小程序文字换行-全是数字的话不会自动换行的解决方法" aria-hidden="true">#</a> 小程序文字换行，全是数字的话不会自动换行的解决方法</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token number">1.</span> 使用   <span class="token operator">&lt;</span>text<span class="token operator">></span>小程序开发\n真的很棒<span class="token operator">&lt;</span><span class="token operator">/</span>text<span class="token operator">></span>   标签，\n是换行符
<span class="token number">2.</span> 全是数字的话在小程序中不会自动换行，需要在css中加一行代码
    word<span class="token operator">-</span>wrap<span class="token operator">:</span><span class="token keyword">break</span><span class="token operator">-</span>word
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="微信小程序自定义tarbra的坑-动态适配iphonex-iphone11等带安全区域的手机" tabindex="-1"><a class="header-anchor" href="#微信小程序自定义tarbra的坑-动态适配iphonex-iphone11等带安全区域的手机" aria-hidden="true">#</a> 微信小程序自定义tarbra的坑，动态适配iphoneX iphone11等带安全区域的手机</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token comment">// 我们只需要在外层的view添加样式</span>
padding<span class="token operator">-</span>bottom<span class="token operator">:</span> <span class="token function">calc</span><span class="token punctuation">(</span><span class="token number">100</span><span class="token function">rpx</span><span class="token punctuation">(</span>高度自己定义<span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token function">env</span><span class="token punctuation">(</span>safe<span class="token operator">-</span>area<span class="token operator">-</span>inset<span class="token operator">-</span>bottom<span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="运营位跳转可以到tabbar页面和二级页面" tabindex="-1"><a class="header-anchor" href="#运营位跳转可以到tabbar页面和二级页面" aria-hidden="true">#</a> 运营位跳转可以到tabbar页面和二级页面</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token comment">// 1、现在js上面把tabbar地址写好</span>
  <span class="token keyword">let</span> tabUrls <span class="token operator">=</span> <span class="token punctuation">[</span>
    <span class="token string">'pages/goodsIndex/goodsIndex'</span><span class="token punctuation">,</span>
    <span class="token string">'pages/getTicket/getTicket'</span><span class="token punctuation">,</span>
    <span class="token string">'pages/cloudShow/cloudShow'</span><span class="token punctuation">,</span>
    <span class="token string">'pages/home/home'</span><span class="token punctuation">,</span>
    <span class="token string">'pages/user/userHome'</span>
  <span class="token punctuation">]</span>
<span class="token comment">// 2、判断url是否为tabbar</span>
<span class="token function">isTab</span><span class="token punctuation">(</span><span class="token parameter">url</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> item <span class="token keyword">of</span> tabUrls<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>url<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span>item<span class="token punctuation">)</span> <span class="token operator">></span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token boolean">true</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// 3、运营位链接跳转</span>
<span class="token function">advUrl</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">let</span> type <span class="token operator">=</span> e<span class="token punctuation">.</span>currentTarget<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>item<span class="token punctuation">.</span>type<span class="token punctuation">;</span>
  <span class="token keyword">var</span> url <span class="token operator">=</span> e<span class="token punctuation">.</span>currentTarget<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>item<span class="token punctuation">.</span>url
  <span class="token comment">//type1为跳转自己的小程序,2为跳转其他小程序，3为跳转wap页</span>
  <span class="token keyword">if</span> <span class="token punctuation">(</span>type <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">isTab</span><span class="token punctuation">(</span>url<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
      wx<span class="token punctuation">.</span><span class="token function">switchTab</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
        url
      <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
      wx<span class="token punctuation">.</span><span class="token function">navigateTo</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
        url
      <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>type <span class="token operator">==</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    wx<span class="token punctuation">.</span><span class="token function">navigateToMiniProgram</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
      <span class="token literal-property property">appId</span><span class="token operator">:</span> e<span class="token punctuation">.</span>currentTarget<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>item<span class="token punctuation">.</span>appid<span class="token punctuation">,</span>
      <span class="token literal-property property">path</span><span class="token operator">:</span> e<span class="token punctuation">.</span>currentTarget<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>item<span class="token punctuation">.</span>url<span class="token punctuation">,</span>
      <span class="token function">complete</span><span class="token punctuation">(</span><span class="token parameter">res</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
    wx<span class="token punctuation">.</span><span class="token function">navigateTo</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
      <span class="token literal-property property">url</span><span class="token operator">:</span> <span class="token string">'/pages/web/web?url='</span> <span class="token operator">+</span> <span class="token function">encodeURIComponent</span><span class="token punctuation">(</span>e<span class="token punctuation">.</span>currentTarget<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>item<span class="token punctuation">.</span>url<span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="禁止input框输入表情" tabindex="-1"><a class="header-anchor" href="#禁止input框输入表情" aria-hidden="true">#</a> 禁止input框输入表情</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token function">inputGoodsName</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">var</span> str <span class="token operator">=</span> e<span class="token punctuation">.</span>detail<span class="token punctuation">.</span>value<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030</span><span class="token regex-delimiter">/</span><span class="token regex-flags">ig</span></span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment">// </span>
  <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setData</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    <span class="token literal-property property">goodsName</span><span class="token operator">:</span>str
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="swiper手动滑动显示总数量-滑动结束隐藏-且轮播图图片高度按照最高一张图片显示" tabindex="-1"><a class="header-anchor" href="#swiper手动滑动显示总数量-滑动结束隐藏-且轮播图图片高度按照最高一张图片显示" aria-hidden="true">#</a> swiper手动滑动显示总数量，滑动结束隐藏，且轮播图图片高度按照最高一张图片显示</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"swiper-box"</span><span class="token operator">></span>
  <span class="token operator">&lt;</span>swiper bindchange<span class="token operator">=</span><span class="token string">"swiperChange"</span> bindanimationfinish<span class="token operator">=</span><span class="token string">"swiperHide"</span> indicator<span class="token operator">-</span>dots<span class="token operator">=</span><span class="token string">"true"</span>  circular<span class="token operator">=</span><span class="token string">"true"</span> indicator<span class="token operator">-</span>color<span class="token operator">=</span><span class="token string">"#CBCBCB"</span> indicator<span class="token operator">-</span>active<span class="token operator">-</span>color<span class="token operator">=</span><span class="token string">"#F8B630"</span> <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"swiper-box"</span> style<span class="token operator">=</span><span class="token string">"height:{{imgheights}}rpx;"</span><span class="token operator">></span> 
    <span class="token operator">&lt;</span>block wx<span class="token operator">:</span><span class="token keyword">for</span><span class="token operator">=</span><span class="token string">"{{userInfo.notesImageList}}"</span> <span class="token literal-property property">wx</span><span class="token operator">:</span>key<span class="token operator">=</span><span class="token string">"*this"</span><span class="token operator">></span>
      <span class="token operator">&lt;</span>swiper<span class="token operator">-</span>item <span class="token operator">></span>
        <span class="token operator">&lt;</span>image mode<span class="token operator">=</span><span class="token string">"aspectFit"</span> bindload<span class="token operator">=</span><span class="token string">"imageLoad"</span> src<span class="token operator">=</span><span class="token string">"{{item.imageUrl}}"</span><span class="token operator">></span><span class="token operator">&lt;</span><span class="token operator">/</span>image<span class="token operator">></span>
      <span class="token operator">&lt;</span><span class="token operator">/</span>swiper<span class="token operator">-</span>item<span class="token operator">></span>
    <span class="token operator">&lt;</span><span class="token operator">/</span>block<span class="token operator">></span>
  <span class="token operator">&lt;</span><span class="token operator">/</span>swiper<span class="token operator">></span>
  <span class="token comment">//  显示数量</span>
  <span class="token operator">&lt;</span>view <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"imageCount"</span> <span class="token literal-property property">wx</span><span class="token operator">:</span><span class="token keyword">if</span><span class="token operator">=</span><span class="token string">"{{showCurrent}}"</span><span class="token operator">></span><span class="token punctuation">{</span><span class="token punctuation">{</span>current<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token operator">/</span><span class="token punctuation">{</span><span class="token punctuation">{</span>userInfo<span class="token punctuation">.</span>notesImageList<span class="token punctuation">.</span>length<span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>
<span class="token operator">&lt;</span><span class="token operator">/</span>view<span class="token operator">></span>

<span class="token comment">//----  data中的数据   --------------</span>
<span class="token literal-property property">imgheights</span><span class="token operator">:</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>    <span class="token comment">//所有图片的高度  </span>
<span class="token literal-property property">current</span><span class="token operator">:</span> <span class="token number">0</span>

<span class="token comment">//获取最高一张图片的高度</span>
<span class="token function">imageLoad</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">var</span> imgArr <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
  <span class="token comment">//当图片载入完毕时</span>
  <span class="token keyword">var</span> imgwidth <span class="token operator">=</span> e<span class="token punctuation">.</span>detail<span class="token punctuation">.</span>width<span class="token punctuation">,</span>
    imgheight <span class="token operator">=</span> e<span class="token punctuation">.</span>detail<span class="token punctuation">.</span>height<span class="token punctuation">,</span>
    <span class="token comment">//宽高比  </span>
    ratio <span class="token operator">=</span> imgwidth <span class="token operator">/</span> imgheight<span class="token punctuation">;</span>
    <span class="token comment">// 计算的高度值</span>
  <span class="token keyword">var</span> viewHeight <span class="token operator">=</span> <span class="token number">750</span> <span class="token operator">/</span> ratio<span class="token punctuation">;</span>
  <span class="token keyword">var</span> imgheight <span class="token operator">=</span> viewHeight<span class="token punctuation">;</span>
  <span class="token comment">//把每一张图片的对应的高度记录到数组里  </span>
  imgArr<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>imgheight<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setData</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    <span class="token literal-property property">imgheights</span><span class="token operator">:</span> Math<span class="token punctuation">.</span><span class="token function">max</span><span class="token punctuation">(</span><span class="token operator">...</span>imgArr<span class="token punctuation">)</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token comment">// 手动滑动轮播图</span>
<span class="token function">swiperChange</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">if</span> <span class="token punctuation">(</span>e<span class="token punctuation">.</span>detail<span class="token punctuation">.</span>source <span class="token operator">==</span> <span class="token string">'touch'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setData</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
      <span class="token literal-property property">current</span><span class="token operator">:</span> e<span class="token punctuation">.</span>detail<span class="token punctuation">.</span>current<span class="token punctuation">,</span>
      <span class="token literal-property property">showCurrent</span><span class="token operator">:</span><span class="token boolean">true</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token function">swiperHide</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setData</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    <span class="token literal-property property">showCurrent</span><span class="token operator">:</span><span class="token boolean">false</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></div></template>


